#include "sim_util.h"

#include "RandomLib/Random.hpp"
#include "RandomLib/NormalDistribution.hpp"
#include "RandomLib/RandomSelect.hpp"

extern RandomLib::Random *RAND;
extern RandomLib::NormalDistribution<float> *NORMDIST;
extern RandomLib::RandomSelect<float> *SELECTDIST;

float sim_util::norm(const float mean, const float sd) {
  return (*NORMDIST)(*RAND, mean, sd);
}
template<typename InputIterator>
unsigned int sim_util::select(InputIterator begin, InputIterator end) {
  SELECTDIST->Init(begin, end);
  return (*SELECTDIST)(*RAND);
}
//SelecteeType can be anything that has [] defined (vectors, maps, arrays)
template<typename InputIterator, typename ReturnType>
ReturnType sim_util::select(InputIterator begin, InputIterator end, ReturnType *choices) {
  return choices[sim_util::select(begin, end)];
}
